package com.ling.schedule;

import com.ling.mapper.UserMapper;
import com.ling.model.User;
import com.ling.service.UserService;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.IJobHandler;
import com.xxl.job.core.handler.annotation.JobHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@JobHandler("mybatisTestJob")
@Component
public class TestJobExecutor extends IJobHandler {
    private Logger logger = LoggerFactory.getLogger(this.getClass());
    @Autowired
    UserService userService;
    @Autowired
    UserMapper userMapper;

    /**
     * 查询
     *
     * @param parm
     * @return
     */
    @Override
    public ReturnT<String> execute(String parm) {
        logger.info("==测试==");
        User user = new User();
        user.setName(parm).setAge(26).setRemark("mybatis_test");
        int result = userMapper.insert(user);
        logger.info("==result==" + result);
        return new ReturnT<>();
    }
}
